package com.learn.egmybatis1.mapper;

import com.learn.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("insert into product(title,price,stock) values(#{title},#{price},#{stock})")
    int insertProduct(Product product);

    @Select("select * from product where id=#{id}")
    Product selectProductById(Integer id);

    @Delete("delete from product where id=#{id}")
    int deleteById(Integer id);

    @Update("update product set title=#{title},price=#{price},stock=#{stock} where id=#{id}")
    int updateProduct(Product product);

    @Select("select * from product")
    List<Product> selectAll();
}
